perm filename 106A35[1,RWF] blob
sn#732988 filedate 1983-11-22 generic text, type C, neo UTF8
COMMENT ā VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 Final Project - Draw Poker (Fall 1983)
C00007 ENDMK
Cā;
Final Project - Draw Poker (Fall 1983)
Program a procedure which chooses the right cards to keep, in a five card draw
poker hand. Assume that an opponent is known to have at least a pair of jacks.
Demonstrate your procedure on the file CS:POKER.DAT, which contains a number of
hands, one per line, in a format like
AH 5C JD 9S 3S
with an asterisk line '*' as a sentinel at the end of the file. Then use the
procedure to tabulate the number of each type of hand after the draw. Our
procedure DEAL (VAR HAND:STRING30), to be found as file CS:DEAL.PGO, uses
random number generation to give the first ten cards in a deal each time it is
called; the first five cards are your original hand, and any discards are
replaced, in sequence, from the next five. Tabulate the types as
BUST, PAIR, TWO PAIR, THREE OF A KIND, STRAIGHT, FLUSH, FULL HOUSE,
FOUR OF A KIND, STRAIGHT FLUSH
For the tabulation, play at least a thousand hands using DEAL as your dealer.
The object of your drawing procedure is to maximize the chance your hand will
_win_, averaging over all the hands your opponent might have after his draw.
You will not be able to program a strategy which always achieves this, but you
should try to come close; demonstrating that your program plays _well_ should be
part of your documentation task.
The file CS:POKER.DAT will be made available on 3:30 pm, the last day of class.
A file CS:POKER.TRY will be available ASAP, but may not be as challenging.
Some Rules of Poker
Five-card hands are ranked in this order, starting with the best type of hand:
5 of a kind, straight flush, 4 of a kind, full house, flush, straight, 3 of a
kind, two pair, bust. Three of a kind means three cards of the same rank;
similar for four and five of a kind. Two of a kind is called a pair. A full
house consists of three of a kind and a pair. A flush is five cards of the
same suit. A straight is five cards of consecutive ranks, with aces being
either highest or lowest. A bust is a hand that doesn't belong to any other
type. A straight flush is both a straight and a flush.
Two hands of the same type are ranked in this way: Hands containing three,
four, or five of a kind are ranked by the rank of the cards of the same kind.
Straights are ranked by their highest card. Flushes are ranked by their highest
card; in case of ties, by the next highest, etc.; same for busts. Hands
containing two pair are ranked, first by the rank of the higher pair, then the
lower pair, then the odd card. Ties are possible in most types. With wild
cards, complexities arise; see Hoyle's _Modern Encyclopedia of Card Games_ or
other rule books.